﻿using HouseKeeperCore.Elemental;
using System.Collections.Generic;

namespace HouseKeeperCore.Hierarchical
{
    /// <summary>
    ///  A class that provides a basic implementation of a group who is an entity and
    ///  able to tag and be tagged
    /// </summary>
    public class Group : TaggedEntity, ITag
    {
        #region Properties

        #region Implementation of ITagging

        /// <summary>
        ///  Enumerates through all entities belongs to the group
        /// </summary>
        public IEnumerable<ITagged> TaggedItems
        {
            get
            {
                foreach (var p in TaggedItemsLookup)
                {
                    yield return p.Value;
                }
            }
        }

        #endregion

        /// <summary>
        ///  A dictionary that holds all the items owned by the group and keys them with their ID
        /// </summary>
        public IDictionary<long, ITagged> TaggedItemsLookup
        {
            get;
            internal set;
        }

        #endregion

        #region Constructors

        /// <summary>
        ///  Instantiates a group with specified ID
        /// </summary>
        /// <param name="id">ID that uniquely identifies the group as an entity</param>
        public Group(long id)
            : base(id)
        {
            TaggedItemsLookup = new Dictionary<long, ITagged>();
        }

        #endregion
    }
}
